// #include <QCoreApplication>

#include <iostream>
using namespace std;

#include "layout.h"
#include "appender.h"
#include "logger.h"

using namespace Log4Qt;

int main(int argc, char *argv[])
{
    // QCoreApplication a(argc, argv);
    // return a.exec();

    QSharedPointer<Layout> layout(new Layout("%d [%12c] - [%p] %F:%l %m"));
    string formatted = layout->format("root", __FILE__, __LINE__, "INFO", "content")
            .toStdString();
    cout << formatted << endl;

    QSharedPointer<Appender> consoleAppender(new ConsoleAppender("console", "GBK", layout));
    consoleAppender->append("root", __FILE__, __LINE__, "INFO", "content-2");
    consoleAppender->append("root", __FILE__, __LINE__, "DEBUG", "测试内容");

    Logger *logger = new Logger("root");
    logger->addAppender(consoleAppender);
    LOG4QT_INFO(logger, "日志信息-1");
    LOG4QT_INFO(logger, "日志信息-2");
}
